package org.example.ioc.process;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * ClassName: MyHappyBeanProcessor
 * Package: org.example.ioc.process
 * Description: 声明一个自定义的bean后置处理器
 *  注意：bean后置处理器不是单独针对某一个bean生效，而是针对IOC容器中所有bean都会执行
 *
 * @Author wanghao
 * @Create 2024-07-03 18:55
 * @Version 1.0
 */
public class MyHappyBeanProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("☆☆☆" + beanName + " = " + bean);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("★★★" + beanName + " = " + bean);
        return bean;
    }
}
